package com.max.mil.fuwu.openapi.yhd;

import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;

import org.json.JSONArray;
import org.json.JSONObject;

import com.max.mil.common.util.DataPage;
import com.max.mil.common.util.HttpTool;
import com.max.mil.common.util.HttpTool.Response;
import com.max.mil.common.util.StringUtil;
import com.max.mil.fuwu.model.yhd.Category;
import com.max.mil.fuwu.model.yhd.FullMinus;
import com.max.mil.fuwu.model.yhd.Product;

public class PromotionApi
{
	
	public static Map<String,Object> cache = new HashMap<String,Object>();
	public static String VID_PREFIX = "VID-";
	
	
	public long addFullMinus(String promotionTitle, int fullMinusType,
			String conditionValues, String contentValues, String productIds,
			String productSerialIds, String categoryIds,
			String brandCategoryIds, String excludeProductIds, int repeat,
			int limitNumPerUser, int joinLevelType, Date startDate, Date endDate)
			throws Exception 
	{
		long id = -1;
		
		String url = "http://openapi.1mall.com/app/api/rest/router";
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("promotionTitle", promotionTitle);
		paramMap.put("fullMinusType", String.valueOf(fullMinusType));
		paramMap.put("conditionValues", conditionValues);
		paramMap.put("contentValues", contentValues);
		paramMap.put("productIds", productIds);
		paramMap.put("productSerialIds", productSerialIds);
		paramMap.put("categoryIds", categoryIds);
		paramMap.put("brandCategoryIds", brandCategoryIds);
		paramMap.put("excludeProductIds", excludeProductIds);
		paramMap.put("repeat", String.valueOf(repeat));
		paramMap.put("limitNumPerUser", String.valueOf(limitNumPerUser));
		paramMap.put("joinLevelType", String.valueOf(joinLevelType));
		paramMap.put("startDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startDate));
		paramMap.put("endDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDate));
		paramMap.put("method", "yhd.promotion.fullminus.add");
		
		JSONObject json = request(url, paramMap);
		JSONObject resp = json.getJSONObject("response");
		checkResp(resp);
		id = resp.getInt("id");
		
		return id;
	}
	
	
	public void delFullMinus(String id) throws Exception 
	{
		String url = "http://openapi.1mall.com/app/api/rest/router";
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("cancelId", id);
		paramMap.put("method", "yhd.promotion.fullminus.cancel");
		
		JSONObject json = request(url, paramMap);
	}
	
	
	public DataPage<FullMinus> getFullMinus(String productId, String productCname,
			String categoryId, int status, Date startDate, Date endDate,
			int pageNo, int pageSize) throws Exception
	{
		int totalCount = 0;
		List<FullMinus> fullMinusList = null;
		
		String url = "http://openapi.1mall.com/app/api/rest/router";
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("productId", productId);
		paramMap.put("productCname", productCname);
		paramMap.put("categoryId", categoryId);
		paramMap.put("status", String.valueOf(status));
		paramMap.put("startDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startDate));
		paramMap.put("endDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDate));
		paramMap.put("curPage", String.valueOf(pageNo));
		paramMap.put("pageRows", String.valueOf(pageSize));
		paramMap.put("method", "yhd.promotion.fullminus.get");
		
		JSONObject json = request(url, paramMap);
		JSONObject resp = json.getJSONObject("response");
		if(resp != null && resp.getInt("errorCount") == 0)
		{
			totalCount = resp.getInt("totalCount");
			JSONObject fullMinusDetailListJson = resp.getJSONObject("fullMinusDetailList");
			if(fullMinusDetailListJson != null)
			{
				JSONArray fullMinusDetailJsonArr = fullMinusDetailListJson.getJSONArray("fullMinusDetail");
				fullMinusList = new ArrayList<FullMinus>();
				
				for(int i=0; i < fullMinusDetailJsonArr.length(); i++)
				{
					JSONObject fullMinusJson = fullMinusDetailJsonArr.getJSONObject(i);
					if(fullMinusJson != null)
					{
						FullMinus fullMinus = new FullMinus();
						fullMinus.setId(fullMinusJson.has("id")?fullMinusJson.getString("id"):null);
						fullMinus.setPromotionTitle(fullMinusJson.has("promotionTitle")?fullMinusJson.getString("promotionTitle"):null);
						fullMinus.setFullMinusType(fullMinusJson.has("fullMinusType")?fullMinusJson.getInt("fullMinusType"):-1);
						fullMinus.setStartDate(fullMinusJson.has("startDate")?new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(fullMinusJson.getString("startDate")):null);
						fullMinus.setEndDate(fullMinusJson.has("endDate")?new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(fullMinusJson.getString("endDate")):null);
						fullMinus.setIsLocked(fullMinusJson.has("isLocked")?fullMinusJson.getInt("isLocked"):-1);
						fullMinus.setStatus(fullMinusJson.has("status")?fullMinusJson.getInt("status"):-1);
						fullMinus.setRepeat(fullMinusJson.has("repeat")?fullMinusJson.getInt("repeat"):-1);
						fullMinus.setLimitNumPerUser(fullMinusJson.has("limitNumPerUser")?fullMinusJson.getInt("limitNumPerUser"):-1);
						fullMinus.setJoinLevelType(fullMinusJson.has("joinLevelType")?fullMinusJson.getInt("joinLevelType"):-1);
						fullMinus.setConditionContents(fullMinusJson.has("conditionContents")?fullMinusJson.getString("conditionContents"):null);
						fullMinus.setExcludeProductIds(fullMinusJson.has("excludeProductIds")?fullMinusJson.getString("excludeProductIds"):null);
						fullMinus.setProductInfo(fullMinusJson.has("productInfo")?fullMinusJson.getString("productInfo"):null);
						fullMinus.setCategoryInfo(fullMinusJson.has("categoryInfo")?fullMinusJson.getString("categoryInfo"):null);
						fullMinus.setBrandCategoryInfo(fullMinusJson.has("brandCategoryInfo")?fullMinusJson.getString("brandCategoryInfo"):null);
						
						fullMinusList.add(fullMinus);
					}
				}
			}
		}
		
		return new DataPage(fullMinusList, pageNo, pageSize, totalCount);
	}
	
	
	public DataPage<FullMinus> getFullMinus(int status, int pageNo, int pageSize)
			throws Exception
	{
		/**1.查询所有促销*/
		List<String> idList = null;
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		int pageNoTmp=1,pageSizeTmp=10,pageCountTmp=1;
		while(pageNoTmp<=pageCountTmp)
		{
			DataPage<FullMinus> dp = getFullMinus(null, null, null, status, 
					dateFormat.parse("2013-01-01 00:00:00"), dateFormat.parse("2016-01-01 00:00:00"), pageNoTmp, pageSizeTmp);
			
			if(dp != null && dp.getList() != null && !dp.getList().isEmpty())
			{
				if(idList == null) idList = new ArrayList<String>();
				for(FullMinus fullMinus:dp.getList())
					idList.add(fullMinus.getId()+"_"+fullMinus.getFullMinusType());
			}
			pageNoTmp++;
			pageCountTmp = dp.getPageCount();
		}
		
		
		/**2.分页查询详情*/
		List<FullMinus> fullMinusList = null;
		DataPage<String> idDp = DataPage.getByList(idList, pageNo, pageSize);
		if(idDp != null && idDp.getList() != null && !idDp.getList().isEmpty())
		{
			for(String id:idDp.getList())
			{
				if(fullMinusList == null)
					fullMinusList = new ArrayList<FullMinus>();
				FullMinus fullMinus = getFullMinusDetail(
						StringUtil.convertInt(id.split("_")[0], -1),StringUtil.convertInt(id.split("_")[1], -1));
				fullMinusList.add(fullMinus);
			}
		}
		
		return new DataPage(fullMinusList, pageNo, pageSize, idList.size());
	}
	
	
	public FullMinus getFullMinusDetail(long id, int fullMinusType) throws Exception 
	{
		FullMinus fullMinus = null;
		
		String url = "http://openapi.1mall.com/app/api/rest/router";
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("id", String.valueOf(id));
		paramMap.put("fullMinusType", String.valueOf(fullMinusType));
		paramMap.put("method", "yhd.promotion.fullminus.detail.get");
		
		JSONObject json = request(url, paramMap);
		JSONObject resp = json.getJSONObject("response");
		if(resp != null && resp.getInt("errorCount") == 0)
		{
			JSONObject fullMinusJson = resp.getJSONObject("fullMinusDetail");
			if(fullMinusJson != null)
			{
				fullMinus = new FullMinus();
				fullMinus.setId(fullMinusJson.has("id")?fullMinusJson.getString("id"):null);
				fullMinus.setPromotionTitle(fullMinusJson.has("promotionTitle")?fullMinusJson.getString("promotionTitle"):null);
				fullMinus.setFullMinusType(fullMinusJson.has("fullMinusType")?fullMinusJson.getInt("fullMinusType"):-1);
				fullMinus.setStartDate(fullMinusJson.has("startDate")?new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(fullMinusJson.getString("startDate")):null);
				fullMinus.setEndDate(fullMinusJson.has("endDate")?new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(fullMinusJson.getString("endDate")):null);
				fullMinus.setIsLocked(fullMinusJson.has("isLocked")?fullMinusJson.getInt("isLocked"):-1);
				fullMinus.setStatus(fullMinusJson.has("status")?fullMinusJson.getInt("status"):-1);
				fullMinus.setRepeat(fullMinusJson.has("repeat")?fullMinusJson.getInt("repeat"):-1);
				fullMinus.setLimitNumPerUser(fullMinusJson.has("limitNumPerUser")?fullMinusJson.getInt("limitNumPerUser"):-1);
				fullMinus.setJoinLevelType(fullMinusJson.has("joinLevelType")?fullMinusJson.getInt("joinLevelType"):-1);
				fullMinus.setConditionContents(fullMinusJson.has("conditionContents")?fullMinusJson.getString("conditionContents"):null);
				fullMinus.setExcludeProductIds(fullMinusJson.has("excludeProductIds")?fullMinusJson.getString("excludeProductIds"):null);
				fullMinus.setProductInfo(fullMinusJson.has("productInfo")?fullMinusJson.getString("productInfo"):null);
				fullMinus.setCategoryInfo(fullMinusJson.has("categoryInfo")?fullMinusJson.getString("categoryInfo"):null);
				fullMinus.setBrandCategoryInfo(fullMinusJson.has("brandCategoryInfo")?fullMinusJson.getString("brandCategoryInfo"):null);
			}
		}
		
		return fullMinus;
	}
	
	
	/**=======================================================================================================*/
//	private DataPage<Product> getProduct(String productCname,String productIdList, String productCodeList,
//			Integer categoryId, Integer merchantCategoryId, int pageNo, int pageSize) throws Exception
//	{
//		List<Product> list = new ArrayList<Product>();
//		
//		int pageNoTmp = 1,totalPage=1;
//		while(pageNoTmp++<=totalPage)
//		{
//			DataPage<Product> dpGenera = getProduct(0, productCname, productIdList, productCodeList,
//					categoryId, merchantCategoryId, pageNoTmp, 100);
//			if(dpGenera.getList() != null) list.addAll(dpGenera.getList());
//		}
//		pageNoTmp = 1;
//		while(pageNoTmp++<=totalPage)
//		{
//			DataPage<Product> dpSerial = getProduct(1, productCname, productIdList, productCodeList,
//					categoryId, merchantCategoryId, pageNoTmp, 100);
//			if(dpSerial.getList() != null) list.addAll(dpSerial.getList());
//		}
//		
//		int totalCount = list.size();
//		list = DataPage.subList(list, pageNo, pageSize);
//		return new DataPage(list, pageNo, pageSize, totalCount);
//	}
	
	public DataPage<Product> getProduct(int type, String productCname, String productIdList, String productCodeList,
			Integer categoryId, Integer merchantCategoryId, int canSale, int canShow, int pageNo, int pageSize) throws Exception
	{
		int totalCount = 0;
		List<Product> productList = null;
		
		String url = "http://openapi.1mall.com/app/api/rest/router";
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("productCname", productCname);
		paramMap.put("productIdList", productIdList);
		paramMap.put("productCodeList", productCodeList);
		paramMap.put("categoryId", String.valueOf(categoryId));
		paramMap.put("merchantCategoryId", String.valueOf(merchantCategoryId));
		paramMap.put("verifyFlg", "2");
		paramMap.put("canSale", String.valueOf(canSale));
		paramMap.put("canShow", String.valueOf(canShow));
		paramMap.put("curPage", String.valueOf(pageNo));
		paramMap.put("pageRows", String.valueOf(pageSize));
		if(type == 0)
			paramMap.put("method", "yhd.general.products.search");
		else
			paramMap.put("method", "yhd.serial.products.search");
		
		JSONObject json = request(url, paramMap);
		JSONObject resp = json.getJSONObject("response");
		if(resp != null && resp.getInt("errorCount") == 0)
		{
			totalCount = resp.getInt("totalCount");
			JSONObject productListJson = resp.getJSONObject(type==0?"productList":"serialProductList");
			if(productListJson != null)
			{
				JSONArray productJsonArr = productListJson.getJSONArray(type==0?"product":"serialProduct");
				productList = new ArrayList<Product>();
				
				for(int i=0; i < productJsonArr.length(); i++)
				{
					JSONObject productJaon = productJsonArr.getJSONObject(i);
					if(productJaon != null)
					{
						Product product = new Product();
						product.setProductCode(productJaon.has("productCode")?productJaon.getString("productCode"):null);
						product.setProductCname(productJaon.has("productCname")?productJaon.getString("productCname"):null);
						product.setProductId(productJaon.has("productId")?productJaon.getLong("productId"):-1L);
						product.setOuterId(productJaon.has("outerId")?productJaon.getString("outerId"):null);
						product.setCanShow(productJaon.has("canShow")?productJaon.getInt("canShow"):-1);
						product.setCanSale(productJaon.has("canSale")?productJaon.getInt("canSale"):-1);
						product.setStockStatus(productJaon.has("stockStatus")?productJaon.getInt("stockStatus"):-1);
						product.setEan13(productJaon.has("ean13")?productJaon.getString("ean13"):null);
						product.setCategoryId(productJaon.has("categoryId")?productJaon.getLong("categoryId"):-1L);
						product.setVerifyFlg(productJaon.has("verifyFlg")?productJaon.getInt("verifyFlg"):-1);
						product.setIsDupAudit(productJaon.has("isDupAudit")?productJaon.getInt("isDupAudit"):-1);
						product.setProdImg(productJaon.has("prodImg")?productJaon.getString("prodImg"):null);
						product.setProdDetailUrl(productJaon.has("prodDetailUrl")?productJaon.getString("prodDetailUrl"):null);
						product.setBrandId(productJaon.has("brandId")?productJaon.getInt("brandId"):-1);
						product.setMerchantCategoryId(productJaon.has("merchantCategoryId")?productJaon.getString("merchantCategoryId"):null);
						product.setMainProductId(productJaon.has("mainProductId")?productJaon.getLong("mainProductId"):-1L);
						product.setMainOuterId(productJaon.has("mainOuterId")?productJaon.getString("mainOuterId"):null);
						
						productList.add(product);
					}
				}
				
				if(productList.size()>pageSize)
					productList = DataPage.subList(productList, pageNo, pageSize);
			}
		}
		
		return new DataPage(productList, pageNo, pageSize, totalCount);
	}
	
	
	public List<Category> getCateList(int type) throws Exception
	{
		List<Category> cateList = null;
		
		String url = "http://openapi.1mall.com/app/api/rest/router";
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("categoryParentId", String.valueOf(0));
		if(type==0)paramMap.put("method", "yhd.category.products.get");
		else paramMap.put("method", "yhd.category.merchant.products.get");
			
		
		JSONObject json = request(url, paramMap);
		JSONObject resp = json.getJSONObject("response");
		if(resp != null && resp.getInt("errorCount") == 0)
		{
			JSONObject categoryInfoListJson = null;
			if(type==0) categoryInfoListJson = resp.getJSONObject("categoryInfoList");
			else categoryInfoListJson = resp.getJSONObject("merchantCategoryInfoList");
			
			if(categoryInfoListJson != null)
			{
				JSONArray categoryInfoJsonArr = null;
				if(type==0) categoryInfoJsonArr = categoryInfoListJson.getJSONArray("categoryInfo");
				else categoryInfoJsonArr = categoryInfoListJson.getJSONArray("merchantCategoryInfo");
				
				cateList = new ArrayList<Category>();
				
				for(int i=0; i < categoryInfoJsonArr.length(); i++)
				{
					JSONObject categoryInfoJson = categoryInfoJsonArr.getJSONObject(i);
					if(categoryInfoJson != null)
					{
						Category cate = new Category();
						if(type==0)
							cate.setCategoryId(categoryInfoJson.has("categoryId")?categoryInfoJson.getLong("categoryId"):-1L);
						else
							cate.setCategoryId(categoryInfoJson.has("merchantCategoryId")?categoryInfoJson.getLong("merchantCategoryId"):-1L);
						cate.setCategoryCode(categoryInfoJson.has("categoryCode")?categoryInfoJson.getString("categoryCode"):null);
						cate.setCategoryName(categoryInfoJson.has("categoryName")?categoryInfoJson.getString("categoryName"):null);
						cate.setCategoryId(categoryInfoJson.has("categoryId")?categoryInfoJson.getLong("categoryId"):-1L);
						
						cateList.add(cate);
					}
				}
			}
		}
		
		return cateList;
	}


	public String fullCutTempletReplace(String id, String title, Date startDate, Date endDate, int fm_type, 
			Integer repeat, Integer jl_type, String aaa, String bbb) throws Exception
	{
		FullMinus fullMinus = null;
		
		if(StringUtil.isEmpty(id))
			id = VID_PREFIX + UUID.randomUUID().toString();
		
		if(id.startsWith(VID_PREFIX))
		{
			fullMinus = new FullMinus();
			fullMinus.setId(id);
			fullMinus.setPromotionTitle(title);
			fullMinus.setStartDate(startDate);
			fullMinus.setEndDate(endDate);
			fullMinus.setFullMinusType(fm_type);
			fullMinus.setRepeat(repeat);
			fullMinus.setJoinLevelType(jl_type);
			fullMinus.setConditionContents(aaa+";"+bbb);
			cache.put(id, fullMinus);
		}
		else
		{
			
		}
			
		
		return id;
	}
	
	
	public String fullCutDetailEdit(String id, String changeInfos)
			throws Exception 
	{
		if(id.startsWith(VID_PREFIX))
		{
			FullMinus fullMinus = (FullMinus)cache.get(id);
			fullMinus.setProductInfo(changeInfos.replaceAll("\\+|-", ""));
			long idL = addFullMinus(fullMinus.getPromotionTitle(), fullMinus.getFullMinusType(), "200,400,600", "10,20,30", 
					fullMinus.getProductInfo(), null, null, null, null, 0, 0, 1, fullMinus.getStartDate(), fullMinus.getEndDate());
			id = String.valueOf(idL);
		}
		else
		{
			
		}
		
		return id;
	}
	
	/**========================================================================================================*/
	private static JSONObject request(String url, Map<String, String> paramMap) throws Exception
	{
		/**1.增加头部参数*/
		paramMap.put("appKey", "10420013082700000187");
		paramMap.put("sessionKey", "4c0810a3834810c04d4db680f3ec657d");
		paramMap.put("format", "json");
		paramMap.put("ver", "1.0");
		paramMap.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		
		/**2.参数签名*/
		Map<String, String> tmpMap = new TreeMap<String, String>();
		tmpMap.putAll(paramMap);
		StringBuffer sb = new StringBuffer().append("e772e2b27c5446eecc1abf9850de0004");
		for(String key:tmpMap.keySet())
		{
			if(tmpMap.get(key) == null)
				paramMap.remove(key);
			else
				sb.append(key).append(tmpMap.get(key));
		}
			
		sb.append("e772e2b27c5446eecc1abf9850de0004");
		String baseStr = sb.toString();
		String signStr = null;
		
		MessageDigest md = MessageDigest.getInstance("MD5");
		signStr = byte2hex(md.digest(baseStr.toString().getBytes("utf-8")));
		paramMap.put("sign", signStr);
		
		
		System.out.println("baseStr="+baseStr);
		System.out.println("signStr="+signStr);
		
		/**3.发起请求*/
		HttpTool httpTool = new HttpTool();
		Response rsp = httpTool.request("POST", url, paramMap);
		System.out.println("rsp="+rsp.asString());
		
		return rsp.asJSONObject();
	}
	
	
	private static void checkResp(JSONObject resp) throws Exception
	{
		String errorCode = "SYSTEM_ERR";
		String errorDes  = "系统繁忙,请您稍后再试!";
		
		if(resp == null || (resp.has("errorCount") && resp.getInt("errorCount") != 0))
		{
			if(resp != null && resp.has("errInfoList"))
			{
				JSONObject errInfoListJson = resp.getJSONObject("errInfoList");
				if(errInfoListJson != null && errInfoListJson.has("errDetailInfo"))
				{
					JSONArray errDetailInfoJsonArray = errInfoListJson.getJSONArray("errDetailInfo");
					if(errDetailInfoJsonArray != null && errDetailInfoJsonArray.length()>0
							&& errDetailInfoJsonArray.getJSONObject(0) != null)
					{
						JSONObject errDetailInfoJson = errDetailInfoJsonArray.getJSONObject(0);
						if(errDetailInfoJson.has("errorCode") && errDetailInfoJson.getString("errorCode") != null)
							errorCode = errDetailInfoJson.getString("errorCode");
						if(errDetailInfoJson.has("errorDes") && errDetailInfoJson.getString("errorDes") != null)
							errorDes = errDetailInfoJson.getString("errorDes");
					}
				}
			}
			
			throw new Exception(errorDes);
		}
	}
	
	private static String byte2hex(byte[] b) 
	{
	     StringBuffer hs = new StringBuffer();
	     String stmp = "";
	     for (int n = 0; n < b.length; n++)
	     {
	         stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
	         if (stmp.length() == 1)
	         hs.append("0").append(stmp);
	         else
	         hs.append(stmp);
	     }
	     
	     return hs.toString();
	}
	
	
	public static void main(String[] args) throws Exception
	{
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		PromotionApi promotionApi = new PromotionApi();
//		promotionApi.addFullMinus("日出东方22", 1, "200,400,600", "10,20,30", "12741155", null, null, null, null, 
//				0, 0, 1,  dateFormat.parse("2013-10-26 17:00:00"), dateFormat.parse("2013-10-26 23:59:59"));
//		yhzService.delFullMinus(137419);
//		System.out.println(promotionApi.getFullMinus(null, null, null, -1, dateFormat.parse("2013-01-01 00:00:00"), dateFormat.parse("2014-01-01 00:00:00"), 1, 10));
//		System.out.println(yhzService.getFullMinusDetail(137419, 1).getId());
//		yhzService.getProduct(1, null, null, null, null, 1, 10);
//		yhzService.getCategoryList(0);
//		yhzService.getCategoryList(1);
//		DataPage<Product> dp = yhzService.getProduct(0, "1mall", "".replaceAll(";", ","), null, null, 1, 10);
		
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("method", "yhd.promotion.price.add");
		paramMap.put("startDate", "2014-01-01 00:00:00");
		paramMap.put("endDate", "2014-01-01 23:59:59");
		paramMap.put("productStr", "12741155,0.8,2,200");
		paramMap.put("productStrSerial", null);
//		paramMap.put("isAttachShippingProm", "0");
//		paramMap.put("postage", "0");
		paramMap.put("isPrice", "0");
		promotionApi.request("http://openapi.1mall.com/app/api/rest/router", paramMap);
		System.out.println("OK");
		
	}
}